import observe from './MVVM/observe';
import Watcher from './MVVM/Watcher';

// for test
window.obj = {
  a: 1,
  b: {
    m: {
      n: 4,
    },
  },
  arr: [{ aa: 11 }],
};

observe(obj);
window.w3 = new Watcher(obj, 'arr', (val) => {
  console.log(`obj.arr 变成了 [${val}]`);
});
console.log(obj);

obj.arr.push({ bb: 22 });
console.log(obj);

// window.w1 = new Watcher(obj, 'a', (val, oldVal) => {
//   console.log(`obj.a 从 ${oldVal}(oldVal) 变成了 ${val}(newVal)`)
// })

// window.w2 = new Watcher(obj, 'b.m.n', (val, oldVal) => {
//   console.log(`obj.b.m.n 从 ${oldVal}(oldVal) 变成了 ${val}(newVal)`)
// })
